package cn.codeforfun.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by Administrator on 2017/2/15 0015.
 */
@Service
@Transactional
public class UserService {
    @Autowired
    private UserDao userDao;

    public User checkUserByUsernameAndPassword(String username, String password) {
        List<User> byUsernameAndPassword = userDao.bizUsernameAndPassword(username, password);
        if (CollectionUtils.isEmpty(byUsernameAndPassword)) {
            return null;
        } else return byUsernameAndPassword.get(0);
    }
}
